<template>
  <d2-container>
    <template slot="header">
      部门： <el-input size="medium" v-model="pageRequest.data.dept"  class="inputBox" style="margin-left:10px;margin-rigth:50px;width: 200px;height: 20px;"></el-input>
      日期： <el-input size="medium" v-model="pageRequest.data.chooseTime"  class="inputBox" style="margin-left:10px;margin-rigth:50px;width: 200px;height: 20px;"></el-input>
            <!-- 日度：<el-date-picker type="date" placeholder="选择日期" v-model="data.chooseTime" style="width: 200px;"></el-date-picker> -->
            <!-- <el-button size="small" type="primary" icon="el-icon-share">分享</el-button> -->
            <div style="float:right">
            <!--查询 重置  -->
            <el-button size="medium" type="primary" icon="el-icon-search" style="margin-left:20px;"  @click="search()">搜索</el-button>
            </div>
    </template>
    <!-- 按钮 -->
    <template>
      <!-- table -->
      <el-button size="medium" type="success" icon="el-icon-s-promotion" style="margin-bottom: 3px;">导出</el-button>
      <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50"> </el-table-column>
        <el-table-column prop="id" label="id" width="100">
        </el-table-column>
        <el-table-column prop="dept" label="部门" width="150">
        </el-table-column>
        <el-table-column prop="assessed" label="被考核人" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="addAward" label="加奖(¥)" show-overflow-tooltip>
        </el-table-column>
                <el-table-column prop="subAward" label="扣奖(¥)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="totalMoney" label="合计" show-overflow-tooltip>
        </el-table-column>
                <el-table-column prop="assessTime" label="考核时间" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope" >
              <el-button size="small"  @click="push2detail(scope.row.id)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <Pagination v-bind:child-msg="pageparm" @callFather="callFather" style="float:right"></Pagination>
    </template>

  </d2-container>

</template>
<style>
  .block {
    float: right;
  }
  .inputBox {
    width: 25%;
  }
  .botton_souch {
    margin-left: 5%;
  }

</style>
<script>
import Pagination from '@/components/Pagination.vue'
export default {
  data () {
    return {
      // 搜索框
      input: '',
      searchInput: {
        assessedName: '',
        check: ''
      },
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 5,
        total: 10

      },
      // 选择器部门
      options: [],
      value: '',
      // 选择器所属指标
      value1: '',
      pageRequest: {
        currentPage: 1,
        limit: 5,
        data: {
          id: 0,
          dept: '',
          assessed: '',
          addAward: 0,
          subAward: 0,
          totalMoney: 0,
          assessTime: '',
          chooseTime: ''
        }
      },

      // table
      tableData: [],
      multipleSelection: []
    }
  },
  // 注册分页组件
  components: {
    Pagination
  },
  // 加载页面就执行的方法
  created () {
    this.getdata()
  },
  // 只有调用才执行的方法
  methods: {
    // 刚进页面的展示
    getdata () {
      this.$request({
        url: 'dailyAssess/summarize',
        method: 'post',
        data: this.pageRequest
      }).then((res) => {
        this.tableData = res.list
        // 初始化分页组件显示总数
        this.pageparm.total = res.total
        console.log(res)
      })
    },
    toggleSelection (rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row)
        })
      } else {
        this.$refs.multipleTable.clearSelection()
      }
    },
    handleSelectionChange (val) {
      this.multipleSelection = val
    },
    // 分页插件事件
    callFather (parm) {
      this.pageRequest.currentPage = parm.currentPage
      this.pageRequest.limit = parm.pageSize
      this.getdata()
    },
    // 搜索事件
    search () {
      this.getdata()
    },
    // 路由跳转
    push2detail (id) {
      this.$router.push({
        path: '/checkassess',
        query: {
          id: id
        }
      })
    }
  }
}
</script>
